home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Wayzata's Best of Shareware PC/Windows 1
/
Wayzata's Best of Shareware for PC-Windows - Release 1 - Wayzata Technology (1993).iso
/
mac
/
DOS
/
GRAPHICS
/
RAYSH386
/
MEMORY.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-30
|
2KB
|
95 lines
/*
* memory.c
*
* Copyright (C) 1989, 1991, Craig E. Kolb
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
* $Id: memory.c,v 4.0 91/07/17 14:30:57 kolb Exp Locker: kolb $
*
* $Log: memory.c,v $
* Revision 4.0 91/07/17 14:30:57 kolb
* Initial version.
*
*/
#ifdef SYSV
#include <memory.h>
#endif
#include "common.h"
unsigned long TotalAllocated;
voidstar
RayMalloc(bytes)
unsigned bytes;
{
voidstar res;
TotalAllocated += bytes;
res = (voidstar)malloc(bytes);
if (res == (voidstar)NULL)
RLerror(RL_PANIC,
"Out of memory trying to allocate %d bytes.\n",bytes,"","");
return res;
}
voidstar
Calloc(nelem, elen)
unsigned nelem, elen;
{
voidstar res;
res = RayMalloc(nelem*elen);
bzero(res, (int)nelem*elen);
return res;
}
void
PrintMemoryStats(fp)
FILE *fp;
{
fprintf(fp,"Total memory allocated:\t\t%lu bytes\n",
TotalAllocated);
}
/*
* Allocate space for a string, copy string into space.
*/
char *
strsave(s)
char *s;
{
char *tmp;
if (s == (char *)NULL)
return (char *)NULL;
tmp = (char *)RayMalloc((unsigned)strlen(s) + 1);
(void)strcpy(tmp, s);
return tmp;
}
#ifdef MULTIMAX
char *
share_calloc(num, siz)
int num;
unsigned int siz;
{
char *res;
res = share_malloc(num*siz);
bzero(res, num*siz);
return res;
}
#endif